package cn.edu.ncut.cs.springboot.springbootmybatisplus.service.impl;

import cn.edu.ncut.cs.springboot.springbootmybatisplus.entity.User;
import cn.edu.ncut.cs.springboot.springbootmybatisplus.mapper.UserMapper;
import cn.edu.ncut.cs.springboot.springbootmybatisplus.service.IUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Optional;
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ncut
 * @since 2024-12-07
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class);
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private PasswordEncoder passwordEncoder;
    @Override
    public Optional<User> getByUsername(@NonNull String username) {
        QueryWrapper<User> qw = new QueryWrapper<>();
        qw.eq("username", username);
        User user = userMapper.selectOne(qw);
        return Optional.ofNullable(user);
    }
}
